package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.FormDataDraftDao;
import com.xbongbong.saas.domain.entity.FormDataDraftEntity;
import com.xbongbong.saas.model.FormDataDraftModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 表单草稿Model层实现
 *
 * @author GuoJun.HU
 * @date 2019/2/19 20:01
 * @since V1.0
 */
@Service("formDataDraftModel")
public class FormDataDraftModelImpl implements FormDataDraftModel {

    @Resource
    private FormDataDraftDao formDataDraftDao;

    @Override
    public Integer insert(FormDataDraftEntity entity) throws XbbException {
        return formDataDraftDao.insert(entity);
    }

    @Override
    public Integer update(FormDataDraftEntity entity) throws XbbException {
        return formDataDraftDao.update(entity);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return formDataDraftDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return formDataDraftDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    /**
     * 批量插入数据
     *
     * @param formDataDraftEntities 草稿实体数据列表
     * @author GuoJun.HU
     * @date 2019/2/19 19:13
     * @since v1.0
     */
    @Override
    public void insertBatch(List<FormDataDraftEntity> formDataDraftEntities) {
        formDataDraftDao.insertBatch(formDataDraftEntities);
    }

    /**
     * 批量删除数据
     *
     * @param idList 草稿实体数据id列表
     * @author GuoJun.HU
     * @date 2019/2/19 19:13
     * @since v1.0
     */
    @Override
    public void deleteBatch(List<Long> idList) {
        formDataDraftDao.deleteBatch(idList);
    }

    /**
     * 根据id查询数据
     *
     * @param key    主键
     * @param corpid 公司ID
     * @author GuoJun.HU
     * @date 2019/2/19 19:13
     * @since v1.0
     */
    @Override
    public FormDataDraftEntity getByKey(Long key, String corpid) {
        return formDataDraftDao.getByKey(key, corpid);
    }

    /**
     * 根据主键删除草稿
     *
     * @param key    主键
     * @param corpid 公司ID
     * @return java.lang.Integer
     * @author GuoJun.HU
     * @date 2019/2/19 19:13
     */
    @Override
    public Integer deleteByKey(Long key, String corpid) {
        return formDataDraftDao.deleteByKey(key, corpid);
    }
}
